import request from './request.js';

export function getPic(searchQuery = 'Korean Idol Face, Pussy', skip = parseInt(Math.random() * 100 * 20), type = 'gifs') {
	let limit = 20;
	return new Promise(rej => {
		uni.request({
			url: `${request.SERVER_URL}/getpic?limit=${limit}&skip=${skip}&searchQuery=${searchQuery}&sort=hot`,
			method: 'GET',
			success: (res) => {
				console.log(res);
				rej(res.data);
			}
		});
	})
}

export function getPic2(prompt = 'naked', options = {}) {
	const { model = 'turbo', seed = Math.floor(Math.random() * 1000000), width = 1024, height = 1024 } = options;
	
	return new Promise((resolve, reject) => {
		uni.request({
			url: `${request.SERVER_URL}/getpic2?prompt=${encodeURIComponent(prompt)}&model=${model}&seed=${seed}&width=${width}&height=${height}`,
			method: 'GET',
			responseType: 'arraybuffer',
			success: (res) => {
				resolve(res.data);
			},
			fail: (err) => {
				console.error('getPic2 error:', err);
				reject(err);
			}
		});
	});
}